﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Net;

namespace MyMusicCollection.Model
{
	class LyricsWikiReader
	{
		//Får tillbaka sångtext som xmldata från en artist och låt
		public XmlTextReader GetLyricsResponse(string aArtist, string aSong)
		{
			string adress = "http://lyricwiki.wikia.com/api.php?func=getSong&artist=" + aArtist + "&song=" + aSong + "&fmt=xml";

			var request = WebRequest.Create(adress) as HttpWebRequest;

			var response = request.GetResponse() as HttpWebResponse;

			if (request.HaveResponse == true && response != null)
			{
				XmlTextReader xmlReader = new XmlTextReader(response.GetResponseStream());
				return xmlReader;
			}

			throw new Exception("Fel när datan skulle hämtas.");
		}
	}
}
